<?php
/**
* This file is part of Webappkit, a packages system for PHP web apps
* @link http://webappkit.net
* @package webappkit
* @author J.Ducastel <jeremie@ducastel.name>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
if (class_exists('waktool'))
	return;

/**
 * Generic tool builder for Kits
 * PHP5 version
 */
class WakTool {
/*--------------------------------------------------------------------
STATIC METHODS
--------------------------------------------------------------------*/
	/**
	 * factory pattern, use this method to build instances
	 * all subclasses have to implement this method
	 * because of PHP object model limitations
	 * @static
	 * @param string $kit_id parent kit id
	 * @param array $cfg configuration data, will be merged with defaults
	 * @return wakTool
	 */
	public static function & Factory($kit_id,$cfg=null) {
		return new WakTool($kit_id,$cfg);
	}
/*--------------------------------------------------------------------
INSTANCE METHODS
--------------------------------------------------------------------*/
	/**
	 * get parent kit's id
	 * @access public
	 * @return string
	 */
	public function getKitId() {
		return $this->kit;
	}

	/**
	 * get configuration data
	 * @access public
	 * @return array
	 */
	public function getCfg() {
		return $this->cfg;
	}
/*--------------------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------------------*/
	/**
	* "real" constructor.
	* will load conf
	* @access public
	* @param string $kit parent kit's id
	* @param string $cfg configuration data, will be merged with defaults
	*/
	protected function __construct($kit,$cfg=null) {
		$this->kit=$kit;
		// importing config
		if (is_array($cfg))
			$this->cfg=Webappkit::mergeArrays($this->cfg,$cfg);
		// doing some more initialization
		$this->_init();
	}/**/
/*--------------------------------------------------------------------
VARS / MEMBERS
--------------------------------------------------------------------*/
	/**
	* @var string parent kit id
	*/
	protected $kit;

	/**
	* @var string self unique name within kit
	*/
	// var $name;

	/**
	 *@var array configuration data (defaults)
	 */
	protected $cfg=array();

	/**
	 * This method will be called by constructor,
	 * once configuration is imported.
	 * implement your post-config stuff there.
	 * @access protected
	 * @return bool
	 */
	protected function _init() {
		return true;
	}
}
?>
